package com.jwell.panrank.ui.dialog

import android.app.Dialog
import android.content.Context
import android.content.DialogInterface
import android.view.LayoutInflater
import android.view.Window
import com.jwell.panrank.R
import kotlinx.android.synthetic.main.dialog_pre_register_notice_layout.view.*

/**
 *  * Created by 76577 on 2018/4/9.
 * 预登记提醒对话框
 */
class PreRegisterNoticeDialog {
    class Builder(private var mContext: Context, list: List<String>) {
        private val isOutTouch = false
        private var list = list
        private var mCancelOnclickListener: DialogInterface.OnClickListener? = null
        private var mEnsureOnclickListener: DialogInterface.OnClickListener? = null

        fun setOnCancelClickListener(listener: DialogInterface.OnClickListener): Builder {
            mCancelOnclickListener = listener
            return this
        }

        fun setOnEnsureClickListener(listener: DialogInterface.OnClickListener?): Builder {
            mEnsureOnclickListener = listener
            return this
        }

        fun create(): Dialog {
            val dialog = Dialog(mContext, R.style.dialog)
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
            val convertView = LayoutInflater.from(mContext).inflate(R.layout.dialog_pre_register_notice_layout, null)
            with(convertView) {
                btn_cancel.setOnClickListener {
                    mCancelOnclickListener?.onClick(dialog, android.content.DialogInterface.BUTTON_NEGATIVE)
                    dialog.dismiss()
                }
                btn_sure.setOnClickListener {
                    mEnsureOnclickListener?.onClick(dialog, android.content.DialogInterface.BUTTON_NEGATIVE)
                    dialog.dismiss()
                }
                dialog.setContentView(convertView)
                dialog.setCanceledOnTouchOutside(isOutTouch)
                return dialog
            }
        }

    }
}